package com.xindaoapp.henghua.protocol.model;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.alibaba.fastjson.JSON;
import com.loopj.android.http.util.MoccaRequest;
import com.loopj.android.http.util.Response.ErrorListener;
import com.loopj.android.http.util.Response.Listener;
import com.xindaoapp.henghua.entry.TransportDataInfo;
import com.xindaoapp.henghua.utils.MoccaPreferences;

public class TransportDataRequest extends MoccaRequest<List<TransportDataInfo>> {

	public TransportDataRequest(String url, Listener<List<TransportDataInfo>> listener,
			ErrorListener errorListener) {
		super(url, listener, errorListener);
	}

	@Override
	public List<TransportDataInfo> parseNetworkResponse(String response) {
		try {
			List<TransportDataInfo> list = JSON.parseArray(new JSONObject(response).getJSONArray("content")
					.toString(), TransportDataInfo.class);
			MoccaPreferences.TRANSPORTDATASTIME.put(new JSONObject(response).getString("currentTime"));
			return list;
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return null;
	}

}
